<!--
 * @Author: your name
 * @Date: 2021-03-15 20:53:56
 * @LastEditTime: 2021-03-15 20:56:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edi
 * @FilePath: \study\js\面试题\数组计算.html
-->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>

    <body>
        <p>闭包</p>

        <script>
            function fn(params) {
                var a = 1;
                function fn1(params) {
                    a++;
                    console.log('fn1', a);
                }
                function fn2(params) {
                    fn1();
                    a++;
                    console.log('fn2', a);
                }
                return fn2;
            }
            var f = fn();
            f();
        </script>
    </body>
</html>
